<template>
  <div class="colored-card" :style="{ '--card-color': cardColor }">
    <div class="card-content">
      <div class="card-header">
        <i :class="icon" :style="{ color: cardColor }"></i> <!-- Dynamically rendered icon -->
        <div class="header-text">
          <h3 :style="{ color: cardColor }">{{ title }}</h3> <!-- Dynamically rendered title with same color -->
          <p>{{ description }}</p> <!-- Dynamically rendered description -->
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ColoredCard',
  props: {
    title: {
      type: String,
      default: 'Card Title', // Default value if no title is passed
    },
    description: {
      type: String,
      default: 'This is a card with a special colored section at the beginning.', // Default description
    },
    icon: {
      type: String,
      default: 'el-icon-info', // Default icon class for Element UI
    },
    cardColor: {
      type: String,
      default: '#ff6347', // Default color (your custom color)
    },
  },
};
</script>

<style scoped>
.colored-card {
  position: relative;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  min-height: 50px;
}

.colored-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 1%;
  height: 100%;
  background-color: var(--card-color, #ff6347);
}

.card-content {
  background-color: #fff;
  padding-left: 20px;
  padding-right: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 20px;
  /* Ensuring icon is on the left and text is on the right */
}

.card-header i {
  font-size: 40px;
  color: #fff;
  /* Icon color is the same as the card color */
}

.header-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-content h3 {
  font-size: 18px;
  margin-bottom: 0px;
}

.card-content p {
  padding-left: 0px;
  font-size: 14px;
  color: #555;
}
</style>
